package com.sun.mvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sun.mvc.exception.BizException;
import com.sun.mvc.exception.SysException;

@Controller
@RequestMapping("/error")
public class ErrorController {
	/**
	 * http://localhost/myproject-web-springmvc/error/bizerror
	 */
	@RequestMapping(value = "/bizerror")
	public void to_bizError() {
		int a = 3;
		int b = 0;
		try {
			int c = a / b;
		} catch (Exception e) {
			throw new BizException("错误提示,{}不能除以{},请修改", a + "", b + "");
		}
	}

	/**
	 * http://localhost/myproject-web-springmvc/error/syserror
	 */
	@RequestMapping(value = "/syserror")
	public void to_sysError() {
		try {
			String a = null;
			if (a.equals("Null")) {
				System.out.print("do something....");
			}
		} catch (Exception e) {
			throw new SysException("系统异常，请联系管理员！", e);
		}
	}
}
